<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript">
        function WebSocketT() {
            if ("WebSocket" in window) {
                console.log("你的浏览器支持WebSocket")
                let ws = new WebSocket("ws://localhost:8099/websocket/2");
                ws.onopen = function () {
                    ws.send("发送数据");
                    alert("数据发送中")
                }
                ws.onmessage = function (evt) {
                    let data = evt.data;
                    alert("数据已接收")
                }
                ws.onclose = function () {
                    alert("连接已经关闭")
                }
            } else {
                console.log("你的浏览器不支持WebSocket!")
            }
        }
    </script>
</head>
<body>
<!--       <button onclick="WebSocket()">发送WebSocket</button>-->
       <div id="sse">
           <a href="javascript:WebSocketT()">运行 WebSocket</a>
       </div>
</body>
</html>
